package cn.wolfcode.trip.base.domain;


import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mycp
 * 大攻略
 */
@Setter @Getter
@JsonIgnoreProperties(value = "json")
public class Strategy extends BaseDomain{
    public static final Integer STATE_NOMAL = 0; //正常
    public static final Integer STATE_DISABLE = 1; //禁用
    public static final Integer STATE_COMMEND = 2; //推荐

    private Region place;// 攻略区域

    private String title;// 攻略标题

    private String subTitle;// 攻略副标题

    private String coverUrl;// 封面

    private Integer state = STATE_NOMAL;// 攻略状态, 默认状态为正常

    public String getStateName(){
        String stateName = "正常";
        if (STATE_COMMEND.equals(state)){
            stateName = "推荐";
        } else if (STATE_DISABLE.equals(state)){
            stateName = "禁用";
        }
        return stateName;
    }

    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", getId());
        map.put("placeId", place.getId());
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        map.put("title", title);
        return JSON.toJSONString(map);
    }
}